_NS_OOP_BEGIN



template< class T >
ResourceSaver&
ResourceSaver::operator<< (const T& r_data)
{
	_outStream << r_data;
	return *this;
}



template< class T >
ResourceSaver&
ResourceSaver::operator<< (const Ptr< T > p_data)
{
	if (p_data == NULL) {
		_outStream << QString ("NULL");
		return *this;
	}
	ResourceSaver ().saveObject (p_data);
	_outStream << p_data->name ();
	return *this;
}



template< class T >
ResourceSaver&
ResourceSaver::operator<< (const std::complex< T >& r_val)
{
	*this << r_val.real () << r_val.imag ();
	return *this;
}



template< class T1, class T2 >
ResourceSaver&
ResourceSaver::operator<< (const std::pair< T1, T2 >& r_val)
{
	*this << r_val.first << r_val.second;
	return *this;
}



template< class T, class _ALLOC >
ResourceSaver&
ResourceSaver::operator<< (const std::vector< T, _ALLOC >& r_val)
{
	*this << r_val.size ();
	for (size_t i = 0; i < r_val.size (); ++i)
		*this << r_val[i];
	return *this;
}



template< class T, class _ALLOC >
ResourceSaver&
ResourceSaver::operator<< (const std::set< T, _ALLOC >& r_val)
{
	*this << r_val.size ();
	for (auto it = r_val.begin (); it != r_val.end (); ++it)
		*this << *it;
	return *this;
}



template< class T1, class T2, class _PR, class _ALLOC >
ResourceSaver&
ResourceSaver::operator<< (const std::map< T1, T2, _PR, _ALLOC >& r_val)
{
	*this << r_val.size ();
	for (auto it = r_val.begin (); it != r_val.end (); ++it)
		*this << it->first << it->second;
	return *this;
}



template< class T >
void
ResourceSaver::writeArray (const T* data, size_t count)
{
	_outStream.readRawData ((char*) data, sizeof (T) * count);
}


template< class T, class _ALLOC >
void
ResourceSaver::writeSimpleVector (const std::vector< T, _ALLOC >& r_vector)
{
	(*this) << r_vector.size ();
	writeArray (&r_vector[0], r_vector.size ());
}



_NS_OOP_END